﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using VisionCloud.Core.Model.Enums;
using VisionCloud.Domain.ModelAttribute;
using static VisionCloud.Core.Model.Sys.SysUser;

namespace VisionCloud.Domain.DtoModel.Ms
{
    /// <summary>
    /// 项目信息
    /// </summary>
    public class ProjectInfoDto
    {
        public Guid ProjectId { get; set; }
        public string ProjectName { get; set; }
        public string ProjectNo { get; set; }
        public string Details { get; set; }
        public long ProjectVersion { get; set; }
        public bool IsDelete { get; set; }
        public bool IsCanPull { get; set; }

        /// <summary>
        /// 根据MsHouseMapDetails计算出来的项目的总面积。
        /// 即已上传户型图的楼层的面积总和。
        /// 之前的没在MsHouseMapDetails的项目，此字段的值就为空
        /// </summary>
        public double? ProjectTotalArea { get; set; }
    }

    /// <summary>
    /// 查询项目楼栋
    /// </summary>
    public class ProjectBuildingStatisDto
    {
        public Guid ProjectId { get; set; }
        public string ProjectName { get; set; }
    }

    /// <summary>
    /// 查询项目楼栋楼层使用
    /// </summary>
    public class ProjectFloorStatisDto
    {
        public Guid ProjectId { get; set; }
        public string ProjectName { get; set; }
        public string BuildingName { get; set; }
    }

    /// <summary>
    /// 项目统计分组
    /// </summary>
    public class ProjectStatisDto
    {
        public Guid ProjectId { get; set; }
        public string ProjectName { get; set; }
        public string BuildingName { get; set; }
        public string FloorName { get; set; }

        public string HouseType { get; set; }

        public string TaskProperty { get; set; }

        /// <summary>
        /// 总测点数
        /// </summary>
        public int TotalPoints { get; set; }

        /// <summary>
        /// 合格点数
        /// </summary>
        public int PassPoints { get; set; }

        /// <summary>
        /// 合格百分比
        /// </summary>
        public string Pass { get; set; }
    }

    /// <summary>
    /// 项目统计分组
    /// </summary>
    public class UserProjectStatisDto
    {
        public Guid YunUserGuid { get; set; }
        public Guid ProjectId { get; set; }
        public string ProjectName { get; set; }

        /// <summary>
        /// 是否可以拉取
        /// </summary>
        public bool? IsCanPull { get; set; }
    }

    /// <summary>
    /// 统计分析项目:不要在这个类添加属性
    /// </summary>
    public class ReportStatisDto
    {
        public string ProjectName { get; set; }
        public string BuildingName { get; set; }
        public string FloorName { get; set; }

        public string HouseType { get; set; }

        public string TaskProperty { get; set; }

        /// <summary>
        /// 排序：初测，复测和“”
        /// </summary>
        public string OrderBy { get; set; }

        /// <summary>
        /// 任务阶段：结构工程、砌筑工程等等
        /// </summary>
        public string ProjectStage { get; set; }
    }

    /// <summary>
    /// 报告列表查询
    /// </summary>
    public class ReportSearchDto : PagerDto
    {
        /// <summary>
        /// 排序字段 ,如果有多个用,分隔
        /// </summary>
        [OrderByField(typeof(ReportDto))]
        public new string OrderBy { get; set; }

        /// <summary>
        /// 项目Id
        /// </summary>
        public string ProjectId { get; set; }

        /// <summary>
        /// 任务名称
        /// </summary>
        public string TaskName { get; set; }

        /// <summary>
        /// 当前用户ID
        /// </summary>
        public Guid UserId { get; set; }

        /// <summary>
        /// 用户类型
        /// </summary>
        public EnumUserType UserType { get; set; }
    }

    /// <summary>
    /// 报告列表查询
    /// </summary>
    public class ReportListSearchDto : PagerDto
    {
        /// <summary>
        /// 项目Id
        /// </summary>
        [GuidRequired] public Guid ProjectId { get; set; }

        /// <summary>
        /// 排序字段 ,如果有多个用,分隔
        /// </summary>
        [OrderByField(typeof(ReportDto))]
        public new string OrderBy { get; set; }

        /// <summary>
        /// 关键字
        /// </summary>
        public string TaskName { get; set; }

        /// <summary>
        /// 任务类型
        /// </summary>
        public MeasureTypeEnum MeasureType { get; set; } = MeasureTypeEnum.实测实量任务;

        /// <summary>
        /// 当前用户ID
        /// </summary>
        public Guid UserId { get; set; }

        /// <summary>
        /// 用户类型
        /// </summary>
        public EnumUserType UserType { get; set; }
    }

    public class NewMessage
    {
        /// <summary>
        /// 任务名称
        /// </summary>
        public string TaskName { get; set; }

        public Guid CSUser2TaskInfoGuid { get; set; }
    }

    /// <summary>
    /// 报告列表查询
    /// </summary>
    public class UserIsReadedTaskDto
    {
        /// <summary>
        ///    任务ID
        /// </summary>
        public Guid TaskId { get; set; }
    }

    /// <summary>
    /// 报告详细信息
    /// </summary>
    public class ReportDto
    {
        /// <summary>
        /// CSUser2TaskInfo IsNew
        /// </summary>
        public bool IsNew { get; set; } = true;

        /// <summary>
        /// 任务名称
        /// </summary>
        public string TaskName { get; set; }

        /// <summary>
        ///  报告上传时间
        /// </summary>
        public DateTime ReportUploadDateTime { get; set; }

        /// <summary>
        /// 同步状态
        /// </summary>
        public bool IsApproved { get; set; }

        /// <summary>
        ///    任务ID
        /// </summary>
        public Guid TaskId { get; set; }

        /// <summary>
        ///  原位标注图路径数组
        /// </summary>
        public List<string> HouseMapPreviewImage { get; set; }

        /// <summary>
        /// 汇总报告路径
        /// </summary>
        public string SummaryReportPath { get; set; }

        /// <summary>
        /// 报告打包文件下载路径
        /// </summary>
        public string CompressedAllFilePath { get; set; }

        /// <summary>
        /// 点云打包下载路径
        /// </summary>
        public string CloudPointCompressedFilePath { get; set; }

        /// <summary>
        /// 结果文件包括：汇总报告，热力图，原位标注图，子站点报告等。
        /// </summary>
        public string ResultDataFilePath { get; set; }

        /// <summary>
        /// 工程阶段
        /// </summary>
        public string ProjectStage { get; set; }

        /// <summary>
        /// 已完成测量报告的站点
        /// </summary>
        public List<long> FinishIndexList { get; set; } = new List<long>();

        /// <summary>
        /// 是否存在热力图基础数据目录
        /// </summary>
        public bool HasHotMap { get; set; } = false;

        /// <summary>
        /// 任务类型
        /// </summary>
        public string TaskType { get; set; }

        public string HouseTypeStr { private get; set; }

        public List<HouseType> HouseTypes { get; set; }
    }
}

public class HouseType
{
    public string Key { get; set; }

    public string Name { get; set; }
}